<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/11/22
  Time: 9:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
  <meta http-equiv="Content-Language" content="zh-cn">
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <link href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css"/>
  <script src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.js"></script>
  <script src="${pageContext.request.contextPath}/bootstrap/js/jquery-3.2.1.min.js"></script>
  <title>产品列表</title>
</head>
<body>
<div style="background-color:#f5fafe;width: 100%;height: 100%;">
  <div class="row">
    <c:forEach var="p" items="${pg.list}">
      <div class="col-xs-2">
        <div class="thumbnail">
          <img src="${pageContext.request.contextPath}/${p.carimages}" alt="..." style="height: 25%">
          <div class="caption">
            <h5 style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap">${p.carname}</h5>
            <p>商场价格：${p.caroriginalprice}</p>
            <p><a href="${pageContext.request.contextPath}/productEditUI.do?carid=${p.carid}" class="btn btn-primary" role="button">修改</a> <a href="${pageContext.request.contextPath}/productDelete.do?carid=${p.carid}" class="btn btn-default" role="button">删除</a></p>
          </div>
        </div>
      </div>
    </c:forEach>
  </div>
  <c:choose>
    <c:when test="${pg.pages<=10}">
      <c:set var="begin" value="1"/>
      <c:set var="end" value="${pg.pages}"/>
    </c:when>
    <c:otherwise>
      <c:set var="begin" value="${pg.pageNum-5}"/>
      <c:set var="end" value="${pg.pageNum+4}"/>
      <c:if test="${begin<1}">
        <c:set var="begin" value="1"/>
        <c:set var="end" value="10"/>
      </c:if>
      <c:if test="${end>pg.pages}">
        <c:set var="begin" value="${pg.pages-9}"/>
        <c:set var="end" value="${pg.pages}"/>
      </c:if>
    </c:otherwise>
  </c:choose>
  <nav aria-label="...">
    <ul class="pagination">
      <li><a href="${pageContext.request.contextPath}/adminProduct.do?page=1">首页</a></li>
      <c:if test="${pg.pageNum ne 1}">
        <li class=""><a href="${pageContext.request.contextPath}/adminProduct.do?page=${pg.prePage}"
                        aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
      </c:if>
      <c:forEach var="num" begin="${begin}" end="${end}">
        <c:choose>
          <c:when test="${num eq pg.pageNum}">
            <li class="active"><span>${num} <span class="sr-only"><%--(current) 注释：当前页码--%></span></span></li>
          </c:when>
          <c:otherwise>
            <li class=""><a href="${pageContext.request.contextPath}/adminProduct.do?page=${num}">${num}</a></li>
          </c:otherwise>
        </c:choose>
      </c:forEach>
      <c:if test="${pg.pageNum ne pg.pages}">
        <li class=""><a href="${pageContext.request.contextPath}/adminProduct.do?page=${pg.nextPage}"
                        aria-label="Previous"><span aria-hidden="true">&raquo;</span></a></li>
      </c:if>
      <li><a href="${pageContext.request.contextPath}/adminProduct.do?page=${pg.pages}">尾页</a></li>
    </ul>
  </nav>

</div>
</body>
</html>
